/*
*
* */
Rsd.define('Rsd.Faith.dialogs.BizZiJinShiYongFenTanViewDialog', {
    extend: 'Rsd.view.MajorSubDialog',
    xtype:'fentan-view-dialog',
    width:1200,
    height:800,
    major:{
        fk:'ShenQingDanHao',
        legend:'',
        header:{content:'&nbsp资金使用信息',position:'top',height:40,align:'left',width:'100%'},
        height:250,
        readOnly:true,
        fields:[
            {
                "name": "ShenQingDanHao",
                "label": {
                    "text": "申请单号",
                    "width": 120
                },
                width:350,
                "xtype": "text"
            },
            {
                "name": "ShenQingJinE",
                "label": {
                    "text": "申请金额",
                    "width": 120
                },
                width:350,
                "xtype": "number",
                "precision": 2
            },
            {
                "name": "ShenQingJinEDaXie",
                "label": {
                    "text": "申请金额大写",
                    "width": 120
                },width:350,
                "xtype": "text"
            },
            {
                "name": "ShenQingRiQi",
                "label": {
                    "text": "申请日期",
                    "width": 120
                },
                width:350,
                "xtype": "date",
                "formatString": "yyyy-MM-dd"
            },
            {
                "name": "ShenQingDanWei",
                "label": {
                    "text": "申请单位",
                    "width": 120
                },
                width:350,
                "xtype": "text"
            },
            {
                "name": "ShenQingDanWeiFaRenDaiBiao",
                "label": {
                    "text": "申请单位法人代表",
                    "width": 120
                },
                width:350,
                "xtype": "text"
            },
            {
                "name": "XiaoQuBianHao",
                "label": {
                    "text": "小区编号",
                    "width": 120
                },
                width:350,
                "xtype": "text"
            },
            {
                "name": "ChuangHao",
                "label": {
                    "text": "楼栋号",
                    "width": 120
                },width:350,
                "xtype": "text"
            },
            {
                "name": "HuaBoZhuangTai",
                "label": {
                    "text": "状态",
                    "width": 120
                },
                width:350,
                "xtype": "text"
            },
            {
                "name": "BoFuFangShi",
                "label": {
                    "text": "拨付方式",
                    "width": 120
                },
                width:350,
                "xtype": "text"
            },
            {
                "name": "ShenQingShiXiang",
                "label": {
                    "text": "申请事项",
                    "width": 120
                },
                width:700,
                "xtype": "text"
            },
            {
                "name": "Remark",
                "label": {
                    "text": "备注",
                    "width": 120
                },width:350,
                "xtype": "text"
            },
            {
                "name": "WeiXiuFanWei",
                "label": {
                    "text": "维修范围",
                    "width": 120
                },
                width:700,
                "xtype": "text"
            }

        ]
    },
    sub:{
        fk:'ShenQingDanHao',
        modelType:'Rsd.Faith.Models.UsingZiJinShiYongFenTanBiaoModel',
        dataSource:'listStore',
        toolBar:{
            xtype:'grid-tool-bar-simple',
            newButtons:[
                {xtype:'label',text:'★ 下方列表为本次资金使用各户分摊明细。👇'}
            ]},
        columns:[
            //{xtype:'checkbox',text:'选择',fixWidth:50},
            {
                "text": "序号",
                "xtype": "index",
                "fixWidth": 40,
                //"sortable": true,
                "index": 0
            },
            /*{
                "name": "ShenQingDanHao",
                "text": "使用申请单号",
                "sortable": true,
                "index": 0,
                "width": 150,
                "nobr": true
            },*/

            /* {
                 "name": "BoFuBianHao",
                 "text": "拨付编号",
                 "sortable": true,
                 "index": 0,
                 "width": 150,
                 "nobr": true
             },*/
            {
                "name": "SuoShuQi",
                "text": "所属期",
                align:'center',
                //"sortable": true,
                "index": 0,
                "width": 80,
                "nobr": true
            },
            {
                "name": "FangWuBianHao",
                "text": "房屋编号",
                //"sortable": true,
                "index": 0,
                "width": 150,
                "nobr": true
            },
            {
                "name": "JianZhuMianJi",
                "text": "建筑面积",
                //"sortable": true,
                "index": 0,
                "xtype": "number",
                "width": 100,
                "precision": 2
            },
            //
            {
                "name": "FenTanJinE",
                "text": "分摊金额",
                //"sortable": true,
                "index": 0,
                "xtype": "number",
                "width": 100,
                "precision": 2
            },
            {
                "name": "HuaBoRiQi",
                "text": "划拨日期",
                //"sortable": true,
                "index": 0,
                "xtype": "date",
                "formatString": "yyyy-MM-dd",
                "width": 100
            },
            {
                "name": "FenTanRiQi",
                "text": "分摊日期",
                //"sortable": true,
                "index": 0,
                "xtype": "date",
                "formatString": "yyyy-MM-dd",
                "width": 100
            },
            {
                "name": "FenTanHouYuE",
                "text": "分摊后余额",
                //"sortable": true,
                "index": 0,
                "xtype": "number",
                "width": 100,
                "precision": 2
            },
            {
                "name": "ZhuangTai",
                "text": "状态",
                //"sortable": true,
                align:'center',
                "index": 0,
                "width": 50,
                "nobr": true
            },
            {
                "name": "Remark",
                "text": "备注",
                //"sortable": true,
                "index": 200,
                "width": 50,
                "nobr": true
            }

        ]
    },
    footer:{
        height:80,style:{fontSize:'120%',left:'50px'},
        items:[
            {
                xtype:'button',
                height:40,
                width:500,
                text:'Ⓢ确 定 入 账',
                handler:'btn_fen_tan_ru_zhang',
                label:{content:'入账后不可分摊不可撤销。',style:{lineHeight:40},position:'right',width:350}
            }]
    },
    /*
    * */
    constructor: function (config) {
        config = config || {};
        Rsd.apply(this, config);
        this.title = '资金使用分摊[申请单号：' + this.data['ShenQingDanHao'] +']';

        if(this.readOnly)
        {
            this.footer.items=[
                {
                    xtype:'button',
                    height:40,
                    width:500,
                    text:'  确  定  ',
                    handler:'btn_ok',
                    label:{content:'- 入帐后计算出分摊后余额 -',style:{lineHeight:40},position:'right',width:350}
                }
            ]
        }
    },

    load:function load() {

        var me = this;

        Rsd.app.requestService('using.getshenqininfo',{ shenqingdanhao:this.data['ShenQingDanHao']},function (data) {

            me.loadMajor(data.data);

            //console.log(data.data);
        });

        Rsd.app.requestService('using.getfentanlist',{shenqingdanhao:this.data['ShenQingDanHao']},function (data) {

            me.loadSub(data.data);

            //console.log(data);
        });
    },
    /*
    * */
    btn_fen_tan_ru_zhang:function btn_fen_tan_ru_zhang()
    {
        var me = this;
        Rsd.app.requestService('using.FengTanRuZhang' ,{ shenqingdanhao:this.data['ShenQingDanHao']},function (data) {
            if(data.success)
            {
                Rsd.popup('【分摊入账】任务已提交');
                me.close();
            }else
            {
                Rsd.alert(data.msg);
            }

        });
    },
    /*
    * */
    btn_ok:function btn_ok() {
        this.close();
        return;
    }
});